import Vue from 'vue'
import VueRouter from 'vue-router'
import Detail from '@/views/Detail.vue'
import Layout from '@/views/Layout.vue'
import Login from '@/views/Login.vue'
import Register from '@/views/Register.vue'
import Like from '@/views/Like'
import Article from '@/views/Article'
import Collect from '@/views/Collect'
import User from '@/views/User'
Vue.use(VueRouter)

const routes = [
  {
    path: '/detail/:id',
    component: Detail
  },
  {
    path: '/',
    component: Layout,
    redirect: '/article',
    children: [
      // 这里是简写，子路由路经只要提供一个路径名即可
      { path: 'article', component: Article },
      { path: 'like', component: Like },
      { path: 'collect', component: Collect },
      { path: 'user', component: User }
    ]
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/register',
    component: Register
  }
]

const router = new VueRouter({
  routes
})

export default router
